package com.leng.exercises;

/**
 * @Author: lengmo
 * @Date: 2019/9/19 17:15
 */
public class Test {
    /**
     * 测试类
     * @param args
     */
    public static void main(String[] args) {
//        twoSum();//1.两数之和
//        addTwoNumbers();//2.两数相加
//        lengthOfLongestSubstring();//3. 无重复字符的最长子串
//        findMedianSortedArrays();//4. 寻找两个有序数组的中位数
        longestPalindrome();//5. 最长回文子串
    }

    //5. 最长回文子串
    private static void longestPalindrome() {
        String s = "babad";
        String result = Solution.longestPalindrome(s);
    }

    //4. 寻找两个有序数组的中位数
    private static void findMedianSortedArrays() {
       int[] nums1 = {1, 3};
       int[] nums2 = {2,4,6,5};
       double result = Solution.findMedianSortedArrays(nums1,nums2);
        System.out.println(result);
    }

    //3. 无重复字符的最长子串
    private static void lengthOfLongestSubstring() {
//        String a = "pwwkew";
//        String a = "aab";
        String a = "dvdf";
        int b = Solution.lengthOfLongestSubstring(a);
        System.out.println(b);
    }

    //2. 两数相加
    public static void addTwoNumbers(){
        Solution.ListNode l1 = new Solution.ListNode(2);
        l1.next = new Solution.ListNode(4);
        l1.next.next = new Solution.ListNode(3);
        Solution.ListNode l2 = new Solution.ListNode(5);
        l2.next = new Solution.ListNode(6);
        l2.next.next = new Solution.ListNode(4);
        Solution.ListNode listNode = Solution.addTwoNumbers(l1, l2);
        while (listNode!=null){
            System.out.print(listNode.val+" ");
            listNode = listNode.next;
        }
    }

    //1. 两数之和
    public static void twoSum(){
        int[] nums = new int[]{3, 2, 4};
        int target = 6;
        int[] ints = Solution.twoSum(nums, target);
        for (int i : ints) {
            System.out.print(i+" ");
        }
    }





}
